#ifndef BUTTON_H
#define BUTTON_H

#include "../Widget.h"
#include <string>

namespace PickinOpenSticks {
    namespace Ui {

        class Button : public Widget {
        public:

            Button() : active(true) {
                SetPos(0, 0);
                text.SetSize(16);
                movable = false;
                type = BUTTON;
            }
            void SetInactiveImage(const std::string& filename);
            void SetActiveImage(const std::string& filename);

            inline void SetText(const std::string& text) {
                this->text.SetText(text);
                SetPos(pos.x, pos.y);
            }
            virtual void SetDefaultImage();

            virtual void SetPos(int x, int y) {
                pos.x = x;
                pos.y = y;
                sprite.SetPosition((float) x, (float) y);
                inactiveSprite.SetPosition((float) x, (float) y);
                text.SetPosition(x + pos.w / 2 - text.GetRect().GetWidth() / 2, y + pos.h / 2 - text.GetRect().GetHeight() / 2);
            }

            inline void Resize(int w, int h) {
                pos.w = w;
                pos.h = h;
                sprite.Resize((float) w, (float) h);
                inactiveSprite.Resize((float) w, (float) h);
            }
        protected:
            void Draw(sf::RenderTarget* target);
            void OnClickPressed(sf::Event* event, bool collided/*=false*/);
            void OnClickReleased(sf::Event* event, bool collided/*=false*/);

            sf::Sprite inactiveSprite;
            bool active;
            sf::String text;



        };
    }
}
#endif
